package com.member.shop.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.member.common.annotation.Excel;
import com.member.common.config.RmConfig;
import com.member.common.constant.SystemConst;
import com.member.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 意见反馈对象 sys_biz_feedback
 *
 * @author thomas
 * @date 2024-11-09
 */
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_biz_feedback")
public class SysBizFeedback extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @TableField(exist = false)
    private SysBizUser user;
    /**
     * 唯一id
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 用户id
     */
    @Excel(name = "用户id")
    private Long userId;

    /**
     * 业务id
     */
    @Excel(name = "业务id")
    private Long bussId;
    /**
     * 联系方式
     */
    @Excel(name = "联系方式")
    private String contact;

    /**
     * 反馈类型（1:系统 2：商品）
     */
    @Excel(name = "反馈类型")
    private Integer type;
    /**
     * 反馈状态( 0 待处理 1 已处理)
     */
    @Excel(name = "反馈状态")
    private Integer status;
    /**
     * 反馈时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "反馈时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime feedbackTime;

    /**
     * 问题描述
     */
    @Excel(name = "问题描述")
    private String description;
    /**
     * 处理时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "处理时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime dealTime;

    /**
     * 处理意见
     */
    @Excel(name = "处理意见")
    private String dealAdvice;

    /**
     * 意见反馈图片
     */
    @Excel(name = "意见反馈图片")
    private String pics;

    public void setPics(String pics) {
        this.pics = pics;
        if (StringUtils.isEmpty(pics)) {
            return;
        }
        String[] split = pics.split(",");
        String domain = RmConfig.getDomain();
        ArrayList<String> strings = new ArrayList<>();

        for (String s : split) {
            String absolute = s;
            if (StringUtils.isNotEmpty(s) && !s.startsWith(SystemConst.HTTP)) {
                absolute = domain + s;
            }
            strings.add(absolute);
        }
        this.picsAbsolute = strings;

    }

    @TableField(exist = false)
    private List<String> picsAbsolute;


}
